#include "magic.h"

Magic::Magic()
{
    power = 5;
    level = 1;
    magicName = "NameMe!";
    luck = 500
}


Magic::Magic(string name, int lvl, int pow, int lk)
{
    power = pow;
    level = lvl;
    magicName = name;
    luck = lk;
}

void Magic::nameMagic(string name)
{
    magicName = name;
}

void Magic::changeLevel(int lvl)
{
    while(++level <= lvl)
    {
        power += (lvl * 2);
        if(luck >= 100)
            luck -= 2;
    }
}

int Magic::attack()
{
    int answer = 0;
    int luckattack = rand() % luck + 1;
    if (luckattack == 1)
    {
        answer = specialAttack();
        return answer;
    }
    else
    {
        answer = rand() % power + 1;
        return answer;
    }
}

